package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.GpcDetail;
import com.stylefeng.guns.modular.system.service.IGpcDetailService;

/**
 * 股票池详细控制器
 *
 * @author fengshuonan
 * @Date 2018-07-23 20:40:06
 */
@Controller
@RequestMapping("/gpcDetail")
public class GpcDetailController extends BaseController {

    private String PREFIX = "/system/gpcDetail/";

    @Autowired
    private IGpcDetailService gpcDetailService;

    /**
     * 跳转到股票池详细首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "gpcDetail.html";
    }

    /**
     * 跳转到添加股票池详细
     */
    @RequestMapping("/gpcDetail_add")
    public String gpcDetailAdd() {
        return PREFIX + "gpcDetail_add.html";
    }

    /**
     * 跳转到修改股票池详细
     */
    @RequestMapping("/gpcDetail_update/{gpcDetailId}")
    public String gpcDetailUpdate(@PathVariable Integer gpcDetailId, Model model) {
        GpcDetail gpcDetail = gpcDetailService.selectById(gpcDetailId);
        model.addAttribute("item",gpcDetail);
        LogObjectHolder.me().set(gpcDetail);
        return PREFIX + "gpcDetail_edit.html";
    }

    /**
     * 获取股票池详细列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return gpcDetailService.selectList(null);
    }

    /**
     * 新增股票池详细
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(GpcDetail gpcDetail) {
        gpcDetailService.insert(gpcDetail);
        return SUCCESS_TIP;
    }

    /**
     * 删除股票池详细
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer gpcDetailId) {
        gpcDetailService.deleteById(gpcDetailId);
        return SUCCESS_TIP;
    }

    /**
     * 修改股票池详细
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(GpcDetail gpcDetail) {
        gpcDetailService.updateById(gpcDetail);
        return SUCCESS_TIP;
    }

    /**
     * 股票池详细详情
     */
    @RequestMapping(value = "/detail/{gpcDetailId}")
    @ResponseBody
    public Object detail(@PathVariable("gpcDetailId") Integer gpcDetailId) {
        return gpcDetailService.selectById(gpcDetailId);
    }
}
